<template>
  <!-- {{ props.tableData }} -->
  <el-table :data="props.tableData" class="mt-3" border>
    <!-- <el-table-column prop="fbillno" label="采订单单号" width="200" /> -->
    <el-table-column prop="fseq" label="行号" width="70" />
    <el-table-column prop="fsupplierid_number" label="供应商代号" min-width="150" />
    <el-table-column prop="fsupplierid_name" label="供应商名称" width="150" />
    <!-- <el-table-column prop="fentryid" label="采购序号" width="150" /> -->
    <el-table-column prop="fmaterialid" label="品号" min-width="150" />
    <el-table-column prop="fmaterialname" label="品名" min-width="200" />
    <el-table-column prop="fmaterialmodel" label="规格" min-width="130" />
    <el-table-column prop="funitid_name" label="单位" min-width="80" />
    <!-- <el-table-column prop="fqty" label="计划数量" min-width="100" /> -->

    <el-table-column prop="quantityreturned" label="退货数量" min-width="180" >
      <template #default="scope">
        <el-input-number v-model="scope.row.quantityreturned" :min="1" />
        <!-- {{ Number(scope.row.putquantity) }} -->
      </template>
    </el-table-column>

    <el-table-column prop="barcode" label="箱号" min-width="200" v-if="tabName == 'details'" />
    <el-table-column prop="FNumber" label="仓库代号" min-width="130" />
    <el-table-column prop="FName" label="仓库名称" min-width="130" />
    <el-table-column prop="warehousecode" label="库位代码" min-width="130" />
    <el-table-column prop="repositoryname" label="库位名称" min-width="130" />
    <el-table-column prop="caigoucreator_id" label="创建者" min-width="130" />
    <!-- <el-table-column label="操作" min-width="130" fixed="right" v-if="props.state != '已审核'">
      <template #default="scope"> <el-button type="warning" @click="editClick(scope.row)">修改</el-button></template>
    </el-table-column> -->
  </el-table>
</template>
  <script lang="ts" setup>
import { computed, onMounted, ref, reactive } from 'vue'
import { useRouter, useRoute } from 'vue-router'
import http from '/admin/support/http'
import { ElMessage } from 'element-plus'
const props = defineProps({
  tableData: Array,
  state: String,
  tabName: String,
})

const num = reactive({
  giveaway: 0,
  putquantity: 0,
})

const putquantityChange = e => {
  console.log('putquantity', e)
  num.putquantity = e
}
const giveawayChange = e => {
  console.log('giveaway', e)
  num.giveaway = e
}

const emit = defineEmits(['sendData'])

const editClick = item => {
  console.log('修改的当前项：', item)
  const data = {
    giveaway: item.giveaway,
    putquantity: item.putquantity,
  }
  console.log('修改提交的data：', data)

  http
    .put(`/purchasing/updatedata/${item.id}`, data)
    .then(r => {
      ElMessage({
        message: r.data.message,
        type: 'success',
      })
    })
    .catch(error => {
      ElMessage({
        message: error.data.message,
        type: 'danger',
      })
    })
  // 修改后是否需要重新刷新
  // emit('sendData')
}

const router = useRouter()
const route = useRoute()
</script>
  
  